import request from './request'
import config from './config'

let defaulHost = config.host;

export default {
    sendGet(url, params, hostName, options) {
        let host = hostName ? config[hostName] : defaulHost;
        let data = {
            method: 'get',
            url: host + url,
            params
        }
        if (options) {
            data = Object.assign(data, options);
        }
        return request(data)
    },

    sendPost(url, params, hostName, options) {
        let host = hostName ? config[hostName] : defaulHost;
        let data = {
            method: 'post',
            url: host + url,
            data: params
        }
        if (options) {
            data = Object.assign(data, options);
        }
        return request(data)
    }
}
